package com.itheima.demo.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author :WuJunJie
 * packageName :com.itheima.demo.aop
 * fileName :LoinAOP
 * creationTime :2022-11-11 16:18
 */
@Component
@Aspect
public class LoinAOP {
    @Pointcut("execution(* com.itheima.demo.controller.LoginController.login(..))")
    public void login(){}

    @Around("login()")
    public Object round(ProceedingJoinPoint pjp) throws Throwable {
        Object[] args = pjp.getArgs();
        for (int i = 0; i < args.length; i++) {
            if(args[i] instanceof String){
                args[i]=args[i].toString().trim();
            }
        }
        Object proceed = pjp.proceed(args);
        return proceed;
    }
}
